﻿package net.wangit.sso;

import java.util.ArrayList;
import java.util.List;

import net.wangit.Path;
import net.wangit.framework.exception.ConfigurationException;
import net.wangit.util.FileUtil;
import net.wangit.util.XMLUtil;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
import org.dom4j.Element;


public class SSOConfig {

	private static Log log;
	private static String path;
	private static List<OutSupport> out = new ArrayList<OutSupport>();
	private static List<InSupport> in = new ArrayList<InSupport>();

	public SSOConfig() {
	}

	public static List<OutSupport> getOutSupports() {
		return out;
	}

	public static List<InSupport> getInSupports() {
		return in;
	}

	static {
		log = LogFactory.getLog(net.wangit.sso.SSOConfig.class);
		path = (new StringBuilder(String.valueOf(Path.getHomePath()))).append(
				"/sso.xml").toString();
		try {
			if (!FileUtil.exists(path)) {
				log.error((new StringBuilder("sms file not found:")).append(
						path).toString());
				throw new ConfigurationException("sms file not found!");
			}
			Document document = XMLUtil.parseByPath(path);
			Element root = document.getRootElement();
			List out = root.elements();
			for (int i = 0; i < out.size(); i++)
				;
			List in = root.elements();
			for (int i = 0; i < in.size(); i++)
				;
		} catch (Exception e) {
			log.error("load sso settings failed!");
			throw new ConfigurationException(path, e);
		}
		log.info("load sso settings successfully.");
	}
}
